clear
cd "D:"
log using JoPReplication.log, name(OuPowerPaper) replace
use PowerExperimentsAllinOne,replace



************************************************************************************
* Ou: "Race to the Top: How Competition for Political Power Affects Participation" *
* Note: All commands are compiled in this one Do file (based on STATA Version 15)  * 
* The analysis is organized by Experiment.                                         *
************************************************************************************





//As noted in the paper, I focus on voting for one's own group's preferred policy as the main dependent variable//
//Subjects rarely voted for the policy preferred by the other group and most of such other party voting happened in the first few periods//
//Whether including voting for the policy preferred by the other group or not does not change our conclusions//
//Analysis of voting for the policy preferred by the other group is reported later in this replication file//

gen Voting=0
replace Voting=1 if GroupA==1&Vote==1
replace Voting=1 if GroupA==0&Vote==2

********************************************************************************
*                                                                              *
*                      Statistical Analysis of Experiment I                    *
*                                                                              *
********************************************************************************          

preserve
keep if Experiment==1
///Generate Electorate Average of Group A Voters' Voting by Voting Game and Treatment///
///Group A's Voting in VG1 of Treatment Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen AVG1Treatment=mean(Voting) if GroupA==1&VotingGame==1&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupAVG1Treatment=mean(AVG1Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG1TreatmentAvg=GroupAVG1Treatment if _n==1
///Group A's Voting in VG2 of Treatment Group///
by UniqueGroupIDbyElectorate: egen AVG2Treatment=mean(Voting) if GroupA==1&VotingGame==2&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2Treatment=mean(AVG2Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2TreatmentAvg=GroupAVG2Treatment if _n==2
///Group A's Voting in VG1 of Control Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen AVG1Control=mean(Voting) if GroupA==1&VotingGame==1&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupAVG1Control=mean(AVG1Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG1ControlAvg=GroupAVG1Control if _n==1
///Group A's Voting in VG2 of Control Group///
by UniqueGroupIDbyElectorate: egen AVG2Control=mean(Voting) if GroupA==1&VotingGame==2&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2Control=mean(AVG2Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2ControlAvg=GroupAVG2Control if _n==2
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///Group B's Voting in VG1 of Treatment Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen BVG1Treatment=mean(Voting) if GroupA==0&VotingGame==1&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupBVG1Treatment=mean(BVG1Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG1TreatmentAvg=GroupBVG1Treatment if _n==1
///Group B's Voting in VG2 of Treatment Group///
by UniqueGroupIDbyElectorate: egen BVG2Treatment=mean(Voting) if GroupA==0&VotingGame==2&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupBVG2Treatment=mean(BVG2Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG2TreatmentAvg=GroupBVG2Treatment if _n==2
///Group B's Voting in VG1 of Control Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen BVG1Control=mean(Voting) if GroupA==0&VotingGame==1&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupBVG1Control=mean(BVG1Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG1ControlAvg=GroupBVG1Control if _n==1
///Group B's Voting in VG2 of Control Group///
by UniqueGroupIDbyElectorate: egen BVG2Control=mean(Voting) if GroupA==0&VotingGame==2&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupBVG2Control=mean(BVG2Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG2ControlAvg=GroupBVG2Control if _n==2
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///Comparisons of Group A's Voting in VG1 Across Treatments/// pp.13 of manuscript
gen AVG1AcrossTreatments=GroupAVG1TreatmentAvg if Treatment==1
replace AVG1AcrossTreatments=GroupAVG1ControlAvg if Treatment==0

ttest AVG1AcrossTreatments,by(Treatment)
ranksum AVG1AcrossTreatments,by(Treatment)

///Comparisons of Group B's Voting in VG1 Across Treatments/// pp.13 of manuscript
gen BVG1AcrossTreatments=GroupBVG1TreatmentAvg if Treatment==1
replace BVG1AcrossTreatments=GroupBVG1ControlAvg if Treatment==0

ttest BVG1AcrossTreatments,by(Treatment)
ranksum BVG1AcrossTreatments,by(Treatment)

///Comparisons of Group A's Voting in VG2 Across Treatments/// pp.13 of manuscript
gen AVG2AcrossTreatments=GroupAVG2TreatmentAvg if Treatment==1
replace AVG2AcrossTreatments=GroupAVG2ControlAvg if Treatment==0

ttest AVG2AcrossTreatments,by(Treatment)
ranksum AVG2AcrossTreatments,by(Treatment)

///Comparisons of Group B's Voting in VG2 Across Treatments/// pp.13 of manuscript
gen BVG2AcrossTreatments=GroupBVG2TreatmentAvg if Treatment==1
replace BVG2AcrossTreatments=GroupBVG2ControlAvg if Treatment==0

ttest BVG2AcrossTreatments,by(Treatment)
ranksum BVG2AcrossTreatments,by(Treatment)
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///Comparisons of Group A' Voting in Control Across VGs/// pp.13 of manuscript
gen GroupAControlAcrossVGs=GroupAVG1ControlAvg if  Treatment==0&GroupAVG1ControlAvg!=.
replace GroupAControlAcrossVGs=GroupAVG2ControlAvg if Treatment==0&GroupAVG2ControlAvg!=.

gen withinControlA=0 if GroupAVG1ControlAvg!=.
replace withinControlA=1 if GroupAVG2ControlAvg!=.

ttest GroupAControlAcrossVGs,by(withinControlA)
ranksum GroupAControlAcrossVGs,by(withinControlA)

///Comparisons of Group A's Voting in Treatment Across VGs/// pp.13 of manuscript
gen GroupATreatmentAcrossVGs=GroupAVG1TreatmentAvg if  Treatment==1&GroupAVG1TreatmentAvg!=.
replace GroupATreatmentAcrossVGs=GroupAVG2TreatmentAvg if Treatment==1&GroupAVG2TreatmentAvg!=.

gen withinTreatmentA=0 if GroupAVG1TreatmentAvg!=.
replace withinTreatmentA=1 if GroupAVG2TreatmentAvg!=.

ttest GroupATreatmentAcrossVGs,by(withinTreatmentA)
ranksum GroupATreatmentAcrossVGs,by(withinTreatmentA)

///Comparisons of Group B' Voting in Control Across VGs/// pp.13 of manuscript
gen GroupBControlAcrossVGs=GroupBVG1ControlAvg if  Treatment==0&GroupBVG1ControlAvg!=.
replace GroupBControlAcrossVGs=GroupBVG2ControlAvg if Treatment==0&GroupBVG2ControlAvg!=.

gen withinControlB=0 if GroupBVG1ControlAvg!=.
replace withinControlB=1 if GroupBVG2ControlAvg!=.

ttest GroupBControlAcrossVGs,by(withinControlB)
ranksum GroupBControlAcrossVGs,by(withinControlB)

///Comparisons of Group B' Voting in Treatment Across VGs/// pp.13 of manuscript
gen GroupBTreatmentAcrossVGs=GroupBVG1TreatmentAvg if  Treatment==1&GroupBVG1TreatmentAvg!=.
replace GroupBTreatmentAcrossVGs=GroupBVG2TreatmentAvg if Treatment==1&GroupBVG2TreatmentAvg!=.

gen withinTreatmentB=0 if GroupBVG1TreatmentAvg!=.
replace withinTreatmentB=1 if GroupBVG2TreatmentAvg!=.

ttest GroupBTreatmentAcrossVGs,by(withinTreatmentB)
ranksum GroupBTreatmentAcrossVGs,by(withinTreatmentB)


////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///To complement the nonparametric statistical tests reported above, I also conduct 
///a regression-based statistical analysis that uses all observations 
///and cluster-robust standard errors that allow for arbitrary correlation between 
///observations from the same electorate. These results are reported in Appendix E
///////////////         Table A1 (Appendix E)        ///////////////////////////

logit Voting Treatment if GroupA==1&VotingGame==1,vce(cluster UniqueElectorateID)
eststo margin11: margins, dydx(*) atmeans  post
estimates store m11, title(Model 1)
logit Voting Treatment if GroupA==0&VotingGame==1,vce(cluster UniqueElectorateID)
eststo margin12: margins,  dydx(*) atmeans  post
estimates store m12, title(Model 2)
logit Voting Treatment if GroupA==1&VotingGame==2,vce(cluster UniqueElectorateID)
eststo margin13: margins,  dydx(*) atmeans  post
estimates store m13, title(Model 3)
logit Voting Treatment if GroupA==0&VotingGame==2,vce(cluster UniqueElectorateID)
eststo margin14: margins, dydx(*) atmeans  post
estimates store m14, title(Model 4)
esttab margin11 margin12 margin13 margin14 using TableA1.txt,cells(b(star fmt(3))/* 
*/se(par fmt(3))) star(* 0.10 ** 0.05 *** 0.01) stats(r2_a N,fmt(%9.3f %9.0g)) legend label collabels(none) replace
restore
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
preserve
keep if Experiment==1
keep if Period==40  
//Examine Elicited Valuation of Participation by Voter and Treatment (Figure 3)//
*post-treatment survey was conducted right after the 40th round of voting and was elicited once*
*generate Electorate Average of Valuations by Group and Treatment*
sort UniqueElectorateID
by UniqueElectorateID: egen GroupAValue=mean(VotingImportance) if GroupA==1
by UniqueElectorateID, sort: egen AMeanValue=mean(GroupAValue)
by UniqueElectorateID: gen GroupAMeanValue=AMeanValue if _n==1
sort UniqueElectorateID
by UniqueElectorateID: egen GroupBValue=mean(VotingImportance) if GroupA==0
by UniqueElectorateID, sort: egen BMeanValue=mean(GroupBValue)
by UniqueElectorateID: gen GroupBMeanValue=BMeanValue if _n==1

ttest GroupAMeanValue,by(Treatment)
ranksum GroupAMeanValue,by(Treatment)

ttest GroupBMeanValue,by(Treatment)
ranksum GroupBMeanValue,by(Treatment)


//Examine Elicited Status-Seeking Preferences by Voter and Treatment (Figure 4)//
*generate Electorate Average of Valuations by Group and Treatment*
sort UniqueElectorateID
by UniqueElectorateID: egen GroupAStatus=mean(EarningMorethanOthers) if GroupA==1
by UniqueElectorateID, sort: egen AMeanStatus=mean(GroupAStatus)
by UniqueElectorateID: gen GroupAMeanStatus=AMeanStatus if _n==1
sort UniqueElectorateID
by UniqueElectorateID: egen GroupBStatus=mean(EarningMorethanOthers) if GroupA==0
by UniqueElectorateID, sort: egen BMeanStatus=mean(GroupBStatus)
by UniqueElectorateID: gen GroupBMeanStatus=BMeanStatus if _n==1

ttest GroupAMeanStatus,by(Treatment)
ranksum GroupAMeanStatus,by(Treatment)

ttest GroupBMeanStatus,by(Treatment)
ranksum GroupBMeanStatus,by(Treatment)
restore
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
///Examine The Likelihood that Policy B Winning Across Treatments (Figure 5)////
*****recall that each Group A voter has 2 ballots in Exp. I*****
preserve
keep if Experiment==1

gen VoteA=0
replace VoteA=2 if Vote==1&GroupA==1
replace VoteA=1 if Vote==1&GroupA==0
gen VoteB=0
replace VoteB=2 if Vote==2&GroupA==1
replace VoteB=1 if Vote==2&GroupA==0

*****compute how many votes are for A and B*****
by UniqueElectionPeriodID, sort: egen V4A=total(VoteA)
by UniqueElectionPeriodID, sort: egen V4B=total(VoteB)


sort UniqueElectorateID Period Subject

gen ProbBWin=0
replace ProbBWin=0.5 if V4A==0&V4B==0
replace ProbBWin=V4B/(V4A+V4B) if V4A+V4B>0

***generate electorate average of computed likelihood Policy B Wins in VG1******
sort UniqueElectorateID
by UniqueElectorateID: egen ProbBWinVG1=mean(ProbBWin) if VotingGame==1
by UniqueElectorateID, sort: egen ProbBWinVG1Avg=mean(ProbBWinVG1)
by UniqueElectorateID: gen VG1ProbBWinElectorateLevel=ProbBWinVG1Avg if _n==1

***generate electorate average of computed likelihood Policy B Wins in VG2******
sort UniqueElectorateID
by UniqueElectorateID: egen ProbBWinVG2=mean(ProbBWin) if VotingGame==2
by UniqueElectorateID, sort: egen ProbBWinVG2Avg=mean(ProbBWinVG2)
by UniqueElectorateID: gen VG2ProbBWinElectorateLevel=ProbBWinVG2Avg if _n==1

*compare electorate average of computed likelihood Policy B Wins by Voting Game*
ttest VG1ProbBWinElectorateLevel,by(Treatment)
ranksum VG1ProbBWinElectorateLevel,by(Treatment)

ttest VG2ProbBWinElectorateLevel,by(Treatment)
ranksum VG2ProbBWinElectorateLevel,by(Treatment)

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///To complement the nonparametric statistical tests reported above, I also conduct 
///a regression-based statistical analysis that uses all observations 
///and cluster-robust standard errors that allow for arbitrary correlation between 
///observations from the same electorate. These results are reported in Appendix E
///////////////         Table A2 (Appendix E)        ///////////////////////////

reg VotingImportance Treatment if GroupA==1,vce(cluster UniqueElectorateID)
outreg2 using TableA2.txt, dec(3) ctitle(Model 1) drop(_Icode*) replace
reg EarningMorethanOthers Treatment if GroupA==1,vce(cluster UniqueElectorateID)
outreg2 using TableA2.txt, dec(3) ctitle(Model 2) drop(_Icode*) append
reg VotingImportance Treatment if GroupA==0,vce(cluster UniqueElectorateID)
outreg2 using TableA2.txt, dec(3) ctitle(Model 3) drop(_Icode*) append
reg EarningMorethanOthers Treatment if GroupA==0,vce(cluster UniqueElectorateID)
outreg2 using TableA2.txt, dec(3) ctitle(Model 4) drop(_Icode*) append
reg ProbBWin Treatment if VotingGame==1,vce(cluster UniqueElectorateID)
outreg2 using TableA2.txt, dec(3) ctitle(Model 5) drop(_Icode*) append
reg ProbBWin Treatment if VotingGame==2,vce(cluster UniqueElectorateID)
outreg2 using TableA2.txt, dec(3) ctitle(Model 6) drop(_Icode*) append
////////////////////////////////////////////////////////////////////////////////
///////////////         Table A3 (Appendix E)        ///////////////////////////

reg ProbBWin Period,vce(cluster UniqueElectorateID)
outreg2 using TableA3.txt, dec(3) ctitle(Model 1) drop(_Icode*) replace
reg ProbBWin Period if Treatment==0,vce(cluster UniqueElectorateID)
outreg2 using TableA3.txt, dec(3) ctitle(Model 2) drop(_Icode*) append
reg ProbBWin Period if Treatment==1,vce(cluster UniqueElectorateID)
outreg2 using TableA3.txt, dec(3) ctitle(Model 3) drop(_Icode*) append
restore
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
*compare task performance across treatments*
*note that Task Stage was played only once at the beginning of the experiment* 
preserve
keep if Experiment==1
ttest TaskPerformance if Period==1,by(Treatment)
ranksum TaskPerformance if Period==1,by(Treatment)

gen TreatmentTaskPerformance=Treatment*TaskPerformance
gen VG1=0
replace VG1=1 if VotingGame==1
gen TreatmentVG1=Treatment*VG1

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///////////////////////         Table 2        /////////////////////////////////
logit Voting Treatment TaskPerformance Period Age Men i.Major CRTScore Competitiveness if GroupA==1,vce(cluster UniqueElectorateID)
eststo margin1: margins, dydx(*) atmeans  post
estimates store m1, title(Model 1)
logit Voting VG1 TaskPerformance Period Age Men i.Major CRTScore Competitiveness if GroupA==1,vce(cluster UniqueElectorateID)
eststo margin2: margins,  dydx(*) atmeans  post
estimates store m2, title(Model 2)
logit Voting Treatment VG1 TreatmentVG1 TaskPerformance Period Age Men i.Major CRTScore Competitiveness if GroupA==1,vce(cluster UniqueElectorateID)
eststo margin3: margins,  dydx(*) atmeans  post
estimates store m3, title(Model 3)
logit Voting Treatment TaskPerformance Period Age Men i.Major CRTScore Competitiveness if GroupA==0,vce(cluster UniqueElectorateID)
eststo margin4: margins, dydx(*) atmeans  post
estimates store m4, title(Model 4)
logit Voting VG1 TaskPerformance Period Age Men i.Major CRTScore Competitiveness if GroupA==0,vce(cluster UniqueElectorateID)
eststo margin5: margins,  dydx(*) atmeans  post
estimates store m5, title(Model 5)
logit Voting Treatment VG1 TreatmentVG1 TaskPerformance Period Age Men i.Major CRTScore Competitiveness if GroupA==0,vce(cluster UniqueElectorateID)
eststo margin6: margins,  dydx(*) atmeans  post
estimates store m6, title(Model 6)

esttab margin1 margin2 margin3 margin4 margin5 margin6 using Table2.txt,cells(b(star fmt(3)) se(par fmt(3))) star(* 0.10 ** 0.05 *** 0.01) stats(r2_a N,fmt(%9.3f %9.0g)) order(Treatment VG1 TreatmentVG1 TaskPerformance Period Age Men CRTScore Competitiveness) legend label collabels(none) replace
////////////////////////////////////////////////////////////////////////////////
////Note: The complete table of results is reported in Table A4 of Appendix E///
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////         Analysis of Otherparty Voting (Appendix D)        /////////////
gen OtherpartyVoting=0
replace OtherpartyVoting=1 if GroupA==1&Vote==2
replace OtherpartyVoting=1 if GroupA==0&Vote==1

summarize OtherpartyVoting if Treatment==0&GroupA==1&VotingGame==1
summarize OtherpartyVoting if Treatment==1&GroupA==1&VotingGame==1
summarize OtherpartyVoting if Treatment==0&GroupA==1&VotingGame==2
summarize OtherpartyVoting if Treatment==1&GroupA==1&VotingGame==2
summarize OtherpartyVoting if Treatment==0&GroupA==0&VotingGame==1
summarize OtherpartyVoting if Treatment==1&GroupA==0&VotingGame==1
summarize OtherpartyVoting if Treatment==0&GroupA==0&VotingGame==2
summarize OtherpartyVoting if Treatment==1&GroupA==0&VotingGame==2

logit OtherpartyVoting Treatment if GroupA==1&VotingGame==1,vce(cluster UniqueElectorateID)
logit OtherpartyVoting Treatment if GroupA==1&VotingGame==2,vce(cluster UniqueElectorateID)
logit OtherpartyVoting Treatment if GroupA==0&VotingGame==1,vce(cluster UniqueElectorateID)
logit OtherpartyVoting Treatment if GroupA==0&VotingGame==2,vce(cluster UniqueElectorateID)


sort UniqueGroupIDbyElectorate
///Group A's OtherpartyVoting in VG2 of Treatment Group///
by UniqueGroupIDbyElectorate: egen AVG2TreatmentO=mean(OtherpartyVoting) if GroupA==1&VotingGame==2&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2TreatmentO=mean(AVG2TreatmentO)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2TreatmentOAvg=GroupAVG2TreatmentO if _n==2

///Group A's OtherpartyVoting in VG2 of Control Group///
by UniqueGroupIDbyElectorate: egen AVG2ControlO=mean(OtherpartyVoting) if GroupA==1&VotingGame==2&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2ControlO=mean(AVG2ControlO)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2ControlOAvg=GroupAVG2ControlO if _n==2

///Comparisons of Group A's OtherpartyVoting in VG2 Across Treatments/// Appendix D
gen AVG2OtherVotingAcrossTreatments=GroupAVG2TreatmentOAvg if Treatment==1
replace AVG2OtherVotingAcrossTreatments=GroupAVG2ControlOAvg if Treatment==0

ttest AVG2OtherVotingAcrossTreatments,by(Treatment)
ranksum AVG2OtherVotingAcrossTreatments,by(Treatment)
restore

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
********************************************************************************
*                                                                              *
*                     Statistical Analysis of Experiment II                    *
*                                                                              *
********************************************************************************
//As noted in the paper, the results of Experiment II are reported in Online Appendix F//
//Again, in Exp II, subjects rarely voted for the policy preferred by the other group and most of such other party voting happened in the first few periods//
//Whether including voting for the policy preferred by the other group or not does not change our conclusions//

preserve
keep if Experiment==2
///Generate Electorate Average of Group A Voters' Voting by Voting Game and Treatment///
///Group A's Voting in VG1 of Treatment Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen AVG1Treatment=mean(Voting) if GroupA==1&VotingGame==1&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupAVG1Treatment=mean(AVG1Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG1TreatmentAvg=GroupAVG1Treatment if _n==1
///Group A's Voting in VG2 of Treatment Group///
by UniqueGroupIDbyElectorate: egen AVG2Treatment=mean(Voting) if GroupA==1&VotingGame==2&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2Treatment=mean(AVG2Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2TreatmentAvg=GroupAVG2Treatment if _n==2
///Group A's Voting in VG1 of Control Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen AVG1Control=mean(Voting) if GroupA==1&VotingGame==1&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupAVG1Control=mean(AVG1Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG1ControlAvg=GroupAVG1Control if _n==1
///Group A's Voting in VG2 of Control Group///
by UniqueGroupIDbyElectorate: egen AVG2Control=mean(Voting) if GroupA==1&VotingGame==2&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2Control=mean(AVG2Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2ControlAvg=GroupAVG2Control if _n==2
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///Group B's Voting in VG1 of Treatment Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen BVG1Treatment=mean(Voting) if GroupA==0&VotingGame==1&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupBVG1Treatment=mean(BVG1Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG1TreatmentAvg=GroupBVG1Treatment if _n==1
///Group B's Voting in VG2 of Treatment Group///
by UniqueGroupIDbyElectorate: egen BVG2Treatment=mean(Voting) if GroupA==0&VotingGame==2&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupBVG2Treatment=mean(BVG2Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG2TreatmentAvg=GroupBVG2Treatment if _n==2
///Group B's Voting in VG1 of Control Group///
sort UniqueGroupIDbyElectorate
by UniqueGroupIDbyElectorate: egen BVG1Control=mean(Voting) if GroupA==0&VotingGame==1&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupBVG1Control=mean(BVG1Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG1ControlAvg=GroupBVG1Control if _n==1
///Group B's Voting in VG2 of Control Group///
by UniqueGroupIDbyElectorate: egen BVG2Control=mean(Voting) if GroupA==0&VotingGame==2&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupBVG2Control=mean(BVG2Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG2ControlAvg=GroupBVG2Control if _n==2
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///Group A voters, in VG1, voted about 43% of the time in the Control and 44% in the Treatment
///and in VG2, voted about 9% of the time in the Control and 12% in the Treatment. 
///Group B voters, in VG1 (VG2), voted about 44% (39%) of the time in the Control 
///and 41% (39%) in the Treatment condition.

///None of these pairwise comparisons are statistically different at the 5% level. 


///Comparisons of Group A's Voting in VG1 Across Treatments/// 
gen AVG1AcrossTreatments=GroupAVG1TreatmentAvg if Treatment==1
replace AVG1AcrossTreatments=GroupAVG1ControlAvg if Treatment==0

*ttest Voting if GroupA==1&VotingGame==1,by(Treatment)
ttest AVG1AcrossTreatments,by(Treatment)
ranksum AVG1AcrossTreatments,by(Treatment)

///Comparisons of Group B's Voting in VG1 Across Treatments/// 
gen BVG1AcrossTreatments=GroupBVG1TreatmentAvg if Treatment==1
replace BVG1AcrossTreatments=GroupBVG1ControlAvg if Treatment==0

*ttest Voting if GroupA==0&VotingGame==1,by(Treatment)
ttest BVG1AcrossTreatments,by(Treatment)
ranksum BVG1AcrossTreatments,by(Treatment)

///Comparisons of Group A's Voting in VG2 Across Treatments/// 
gen AVG2AcrossTreatments=GroupAVG2TreatmentAvg if Treatment==1
replace AVG2AcrossTreatments=GroupAVG2ControlAvg if Treatment==0

*ttest Voting if GroupA==1&VotingGame==2,by(Treatment)
ttest AVG2AcrossTreatments,by(Treatment)
ranksum AVG2AcrossTreatments,by(Treatment)

///Comparisons of Group B's Voting in VG2 Across Treatments/// 
gen BVG2AcrossTreatments=GroupBVG2TreatmentAvg if Treatment==1
replace BVG2AcrossTreatments=GroupBVG2ControlAvg if Treatment==0

*ttest Voting if GroupA==0&VotingGame==2,by(Treatment)
ttest BVG2AcrossTreatments,by(Treatment)
ranksum BVG2AcrossTreatments,by(Treatment)
restore

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///Looking at the self-reported values regarding how important it is for an individual to vote, 
///Group A's average is 5.09 in the Control and 4.91 in the Treatment. 
///Group B's average is 5.08 in the Control and 5.19 in the Treatment. 
///Regarding how important it is for an individual to earn more than the others, 
///Group A's average is 5.44 in the Control and 5.19 in the Treatment. Group B's average is 5.48 in the Control and 5.29 in the Treatment. 

///None of these pairwise comparisons are statistically different at the 5% level. 

preserve
keep if Experiment==2
keep if Period==40  
*post-treatment survey was conducted right after the 40th round of voting and was elicited once*
*generate Electorate Average of Valuations by Group and Treatment*
sort UniqueElectorateID
by UniqueElectorateID: egen GroupAValue=mean(VotingImportance) if GroupA==1
by UniqueElectorateID, sort: egen AMeanValue=mean(GroupAValue)
by UniqueElectorateID: gen GroupAMeanValue=AMeanValue if _n==1
sort UniqueElectorateID
by UniqueElectorateID: egen GroupBValue=mean(VotingImportance) if GroupA==0
by UniqueElectorateID, sort: egen BMeanValue=mean(GroupBValue)
by UniqueElectorateID: gen GroupBMeanValue=BMeanValue if _n==1

ttest GroupAMeanValue,by(Treatment)
ranksum GroupAMeanValue,by(Treatment)

ttest GroupBMeanValue,by(Treatment)
ranksum GroupBMeanValue,by(Treatment)


*generate Electorate Average of Valuations by Group and Treatment*
sort UniqueElectorateID
by UniqueElectorateID: egen GroupAStatus=mean(EarningMorethanOthers) if GroupA==1
by UniqueElectorateID, sort: egen AMeanStatus=mean(GroupAStatus)
by UniqueElectorateID: gen GroupAMeanStatus=AMeanStatus if _n==1
sort UniqueElectorateID
by UniqueElectorateID: egen GroupBStatus=mean(EarningMorethanOthers) if GroupA==0
by UniqueElectorateID, sort: egen BMeanStatus=mean(GroupBStatus)
by UniqueElectorateID: gen GroupBMeanStatus=BMeanStatus if _n==1

ttest GroupAMeanStatus,by(Treatment)
ranksum GroupAMeanStatus,by(Treatment)

ttest GroupBMeanStatus,by(Treatment)
ranksum GroupBMeanStatus,by(Treatment)
restore
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/////////            Examine Voting Outcomes Across Treatments          ////////
////////////////////////////////////////////////////////////////////////////////
*****recall that each Group A voter has 1 ballot in Exp. II*****
preserve
keep if Experiment==2

gen VoteA=0
replace VoteA=1 if Vote==1&GroupA==1
replace VoteA=1 if Vote==1&GroupA==0
gen VoteB=0
replace VoteB=1 if Vote==2&GroupA==1
replace VoteB=1 if Vote==2&GroupA==0

*****compute how many votes are for A and B*****
by UniqueElectionPeriodID, sort: egen V4A=total(VoteA)
by UniqueElectionPeriodID, sort: egen V4B=total(VoteB)


sort UniqueElectorateID Period Subject

gen ProbBWin=0
replace ProbBWin=0.5 if V4A==0&V4B==0
replace ProbBWin=V4B/(V4A+V4B) if V4A+V4B>0

***generate electorate average of computed likelihood Policy B Wins in VG1******
sort UniqueElectorateID
by UniqueElectorateID: egen ProbBWinVG1=mean(ProbBWin) if VotingGame==1
by UniqueElectorateID, sort: egen ProbBWinVG1Avg=mean(ProbBWinVG1)
by UniqueElectorateID: gen VG1ProbBWinElectorateLevel=ProbBWinVG1Avg if _n==1

***generate electorate average of computed likelihood Policy B Wins in VG2******
sort UniqueElectorateID
by UniqueElectorateID: egen ProbBWinVG2=mean(ProbBWin) if VotingGame==2
by UniqueElectorateID, sort: egen ProbBWinVG2Avg=mean(ProbBWinVG2)
by UniqueElectorateID: gen VG2ProbBWinElectorateLevel=ProbBWinVG2Avg if _n==1

*compare electorate average of computed likelihood Policy B Wins by Voting Game*
*ttest ProbBWin if VotingGame==1,by(Treatment)
ttest VG1ProbBWinElectorateLevel,by(Treatment)
ranksum VG1ProbBWinElectorateLevel,by(Treatment)

*ttest ProbBWin if VotingGame==2,by(Treatment)
ttest VG2ProbBWinElectorateLevel,by(Treatment)
ranksum VG2ProbBWinElectorateLevel,by(Treatment)
restore


////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
********************************************************************************
*                                                                              *
*      Comparisons between Experiment I and Experiment II (Figure 6)           *
*                                                                              *
********************************************************************************
preserve
drop if Experiment==3
///Generate Electorate Average of Group A Voters' Voting by Voting Game, Treatment and Experiment///

sort UniqueGroupIDbyElectorate

///Group A's Voting in VG2 of Treatment Group///
by UniqueGroupIDbyElectorate: egen AVG2Treatment=mean(Voting) if GroupA==1&VotingGame==2&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2Treatment=mean(AVG2Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2TreatmentAvg=GroupAVG2Treatment if _n==2

///Group A's Voting in VG2 of Control Group///
by UniqueGroupIDbyElectorate: egen AVG2Control=mean(Voting) if GroupA==1&VotingGame==2&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupAVG2Control=mean(AVG2Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupAVG2ControlAvg=GroupAVG2Control if _n==2
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

///Group B's Voting in VG2 of Treatment Group///
by UniqueGroupIDbyElectorate: egen BVG2Treatment=mean(Voting) if GroupA==0&VotingGame==2&Treatment==1
by UniqueGroupIDbyElectorate, sort: egen GroupBVG2Treatment=mean(BVG2Treatment)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG2TreatmentAvg=GroupBVG2Treatment if _n==2

///Group B's Voting in VG2 of Control Group///
by UniqueGroupIDbyElectorate: egen BVG2Control=mean(Voting) if GroupA==0&VotingGame==2&Treatment==0
by UniqueGroupIDbyElectorate, sort: egen GroupBVG2Control=mean(BVG2Control)
sort UniqueGroupIDbyElectorate Period Subject 
by UniqueGroupIDbyElectorate: gen GroupBVG2ControlAvg=GroupBVG2Control if _n==2

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///  Comparisons of Group A's Voting in VG2 of Treatment Across Experiments  ///
gen GroupAVG2TreatmentAcrossExps=GroupAVG2TreatmentAvg if Treatment==1&Experiment==1
replace GroupAVG2TreatmentAcrossExps=GroupAVG2TreatmentAvg if Treatment==1&Experiment==2
ttest GroupAVG2TreatmentAcrossExps,by(Experiment)
ranksum GroupAVG2TreatmentAcrossExps,by(Experiment)
////////////////////////////////////////////////////////////////////////////////
///  Comparisons of Group B's Voting in VG2 of Treatment Across Experiments  ///
gen GroupBVG2TreatmentAcrossExps=GroupBVG2TreatmentAvg if Treatment==1&Experiment==1
replace GroupBVG2TreatmentAcrossExps=GroupBVG2TreatmentAvg if Treatment==1&Experiment==2
ttest GroupBVG2TreatmentAcrossExps,by(Experiment)
ranksum GroupBVG2TreatmentAcrossExps,by(Experiment)
////////////////////////////////////////////////////////////////////////////////
///   Comparisons of Group A's Voting in VG2 of Control Across Experiments   ///
gen GroupAVG2ControlAcrossExps=GroupAVG2ControlAvg if Treatment==0&Experiment==1
replace GroupAVG2ControlAcrossExps=GroupAVG2ControlAvg if Treatment==0&Experiment==2
ttest GroupAVG2ControlAcrossExps,by(Experiment)
ranksum GroupAVG2ControlAcrossExps,by(Experiment)
////////////////////////////////////////////////////////////////////////////////
///   Comparisons of Group B's Voting in VG2 of Control Across Experiments   ///
gen GroupBVG2ControlAcrossExps=GroupBVG2ControlAvg if Treatment==0&Experiment==1
replace GroupBVG2ControlAcrossExps=GroupBVG2ControlAvg if Treatment==0&Experiment==2
ttest GroupBVG2ControlAcrossExps,by(Experiment)
ranksum GroupBVG2ControlAcrossExps,by(Experiment)
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
gen ExperimentI=0
replace ExperimentI=1 if Experiment==1

logit Voting ExperimentI if VotingGame==2&GroupA==1&Treatment==0,vce(cluster UniqueGroupIDbyElectorate)
eststo margin1: margins, dydx(*) atmeans  post
estimates store m1, title(Model 1)
logit Voting ExperimentI if VotingGame==2&GroupA==0&Treatment==0,vce(cluster UniqueGroupIDbyElectorate)
eststo margin2: margins,  dydx(*) atmeans  post
estimates store m2, title(Model 2)
logit Voting ExperimentI if VotingGame==2&GroupA==1&Treatment==1,vce(cluster UniqueGroupIDbyElectorate)
eststo margin3: margins, dydx(*) atmeans  post
estimates store m3, title(Model 3)
logit Voting ExperimentI if VotingGame==2&GroupA==0&Treatment==1,vce(cluster UniqueGroupIDbyElectorate)
eststo margin4: margins,  dydx(*) atmeans  post
estimates store m4, title(Model 4)
////////////////////////////////////////////////////////////////////////////////
/////////        Generate Table A5 reported in Online Appendix F       /////////
////////////////////////////////////////////////////////////////////////////////
esttab margin1 margin2 margin3 margin4 using TableA5.txt,cells(b(star fmt(3)) se(par fmt(3))) star(* 0.10 ** 0.05 *** 0.01) stats(r2_a N,fmt(%9.3f %9.0g)) legend label collabels(none) replace
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///I examine whether Group A's and Group B's task performance in Treatment of Experiment I
///is different from Group A's and Group B's task performance in Treatment of Experiment II
///None of the following pairwise comparisons are statistically different at the 5% level.
////////////////////////////////////////////////////////////////////////////////
ttest TaskPerformance if GroupA==1&Period==1&Treatment==1,by(Experiment)
ksmirnov TaskPerformance if GroupA==1&Period==1&Treatment==1,by(Experiment)
ttest TaskPerformance if GroupA==0&Period==1&Treatment==1,by(Experiment)
ksmirnov TaskPerformance if GroupA==0&Period==1&Treatment==1,by(Experiment)
restore



////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
********************************************************************************
*                                                                              *
*                    Statistical Analysis of Experiment III                    *
*                                                                              *
********************************************************************************
preserve
keep if Experiment==3
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// In the first 15 periods of Experiment III, individuals received no feedback
////////////////////////////////////////////////////////////////////////////////
//////////////    Results of Appendix G (Figure A5)     ////////////////////////
/// I compute and compare individual level averages of voting by Subject and Treatment of Period<=15
////////////////////////////////////////////////////////////////////////////////

/// Group A VG1
sort UniqueSubjectID
by UniqueSubjectID: egen ATreatmentVG1=mean(Voting) if GroupA==1&VotingGame==1&Treatment==1&Period<=15
by UniqueSubjectID, sort: egen GroupATreatmentVG1=mean(ATreatmentVG1)
by UniqueSubjectID: gen GroupAVG1TreatmentAvg=GroupATreatmentVG1 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen AControlVG1=mean(Voting) if GroupA==1&VotingGame==1&Treatment==0&Period<=15
by UniqueSubjectID, sort: egen GroupAControlVG1=mean(AControlVG1)
by UniqueSubjectID: gen GroupAVG1ControlAvg=GroupAControlVG1 if _n==1


gen GroupAVG1AcorssTreatments=GroupAVG1TreatmentAvg if Treatment==1
replace GroupAVG1AcorssTreatments=GroupAVG1ControlAvg if Treatment==0
ttest GroupAVG1AcorssTreatments,by(Treatment)
ranksum GroupAVG1AcorssTreatments,by(Treatment)

/// Group B VG1
sort UniqueSubjectID
by UniqueSubjectID: egen BTreatmentVG1=mean(Voting) if GroupA==0&VotingGame==1&Treatment==1&Period<=15
by UniqueSubjectID, sort: egen GroupBTreatmentVG1=mean(BTreatmentVG1)
by UniqueSubjectID: gen GroupBVG1TreatmentAvg=GroupBTreatmentVG1 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen BControlVG1=mean(Voting) if GroupA==0&VotingGame==1&Treatment==0&Period<=15
by UniqueSubjectID, sort: egen GroupBControlVG1=mean(BControlVG1)
by UniqueSubjectID: gen GroupBVG1ControlAvg=GroupBControlVG1 if _n==1


gen GroupBVG1AcorssTreatments=GroupBVG1TreatmentAvg if Treatment==1
replace GroupBVG1AcorssTreatments=GroupBVG1ControlAvg if Treatment==0
ttest GroupBVG1AcorssTreatments,by(Treatment)
ranksum GroupBVG1AcorssTreatments,by(Treatment)

/// Group A VG2
sort UniqueSubjectID
by UniqueSubjectID: egen ATreatmentVG2=mean(Voting) if GroupA==1&VotingGame==2&Treatment==1&Period<=15
by UniqueSubjectID, sort: egen GroupATreatmentVG2=mean(ATreatmentVG2)
by UniqueSubjectID: gen GroupAVG2TreatmentAvg=GroupATreatmentVG2 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen AControlVG2=mean(Voting) if GroupA==1&VotingGame==2&Treatment==0&Period<=15
by UniqueSubjectID, sort: egen GroupAControlVG2=mean(AControlVG2)
by UniqueSubjectID: gen GroupAVG2ControlAvg=GroupAControlVG2 if _n==1


gen GroupAVG2AcorssTreatments=GroupAVG2TreatmentAvg if Treatment==1
replace GroupAVG2AcorssTreatments=GroupAVG2ControlAvg if Treatment==0
ttest GroupAVG2AcorssTreatments,by(Treatment)
ranksum GroupAVG2AcorssTreatments,by(Treatment)

/// Group B VG2
sort UniqueSubjectID
by UniqueSubjectID: egen BTreatmentVG2=mean(Voting) if GroupA==0&VotingGame==2&Treatment==1&Period<=15
by UniqueSubjectID, sort: egen GroupBTreatmentVG2=mean(BTreatmentVG2)
by UniqueSubjectID: gen GroupBVG2TreatmentAvg=GroupBTreatmentVG2 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen BControlVG2=mean(Voting) if GroupA==0&VotingGame==2&Treatment==0&Period<=15
by UniqueSubjectID, sort: egen GroupBControlVG2=mean(BControlVG2)
by UniqueSubjectID: gen GroupBVG2ControlAvg=GroupBControlVG2 if _n==1


gen GroupBVG2AcorssTreatments=GroupBVG2TreatmentAvg if Treatment==1
replace GroupBVG2AcorssTreatments=GroupBVG2ControlAvg if Treatment==0
ttest GroupBVG2AcorssTreatments,by(Treatment)
ranksum GroupBVG2AcorssTreatments,by(Treatment)


/// Group A VG3
sort UniqueSubjectID
by UniqueSubjectID: egen ATreatmentVG3=mean(Voting) if GroupA==1&VotingGame==3&Treatment==1&Period<=15
by UniqueSubjectID, sort: egen GroupATreatmentVG3=mean(ATreatmentVG3)
by UniqueSubjectID: gen GroupAVG3TreatmentAvg=GroupATreatmentVG3 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen AControlVG3=mean(Voting) if GroupA==1&VotingGame==3&Treatment==0&Period<=15
by UniqueSubjectID, sort: egen GroupAControlVG3=mean(AControlVG3)
by UniqueSubjectID: gen GroupAVG3ControlAvg=GroupAControlVG3 if _n==1


gen GroupAVG3AcorssTreatments=GroupAVG3TreatmentAvg if Treatment==1
replace GroupAVG3AcorssTreatments=GroupAVG3ControlAvg if Treatment==0
ttest GroupAVG3AcorssTreatments,by(Treatment)
ranksum GroupAVG3AcorssTreatments,by(Treatment)

/// Group B VG3
sort UniqueSubjectID
by UniqueSubjectID: egen BTreatmentVG3=mean(Voting) if GroupA==0&VotingGame==3&Treatment==1&Period<=15
by UniqueSubjectID, sort: egen GroupBTreatmentVG3=mean(BTreatmentVG3)
by UniqueSubjectID: gen GroupBVG3TreatmentAvg=GroupBTreatmentVG3 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen BControlVG3=mean(Voting) if GroupA==0&VotingGame==3&Treatment==0&Period<=15
by UniqueSubjectID, sort: egen GroupBControlVG3=mean(BControlVG3)
by UniqueSubjectID: gen GroupBVG3ControlAvg=GroupBControlVG3 if _n==1


gen GroupBVG3AcorssTreatments=GroupBVG3TreatmentAvg if Treatment==1
replace GroupBVG3AcorssTreatments=GroupBVG3ControlAvg if Treatment==0
ttest GroupBVG3AcorssTreatments,by(Treatment)
ranksum GroupBVG3AcorssTreatments,by(Treatment)
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////    Results of Appendix H (Figure A6 and A7)     /////////////////////
///To understand the influence of voting interactions on self-reported values, I asked
///the same survey questions in Experiment III after participants played voting games for
///15 periods with no feedback.
///compare selfreported Valuation of Participation and Earning more than others in the absence of feedback (Period<=15)
////////////////////////////////////////////////////////////////////////////////
ttest VotingImportance if GroupA==1&Period==16,by(Treatment)
ranksum VotingImportance if GroupA==1&Period==16,by(Treatment)

ttest VotingImportance if GroupA==0&Period==16,by(Treatment)
ranksum VotingImportance if GroupA==0&Period==16,by(Treatment)

ttest EarningMorethanOthers if GroupA==1&Period==16,by(Treatment)
ranksum EarningMorethanOthers if GroupA==1&Period==16,by(Treatment)

ttest EarningMorethanOthers if GroupA==0&Period==16,by(Treatment)
ranksum EarningMorethanOthers if GroupA==0&Period==16,by(Treatment)
restore
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////                 Results of Appendix I           /////////////////////
preserve
keep if Experiment==3
keep if Period>15
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// I compute and compare individual level averages of voting by Subject and Treatment of Period>15
////////////////////////////////////////////////////////////////////////////////

/// Group A VG1
sort UniqueSubjectID
by UniqueSubjectID: egen ATreatmentVG1=mean(Voting) if GroupA==1&VotingGame==1&Treatment==1
by UniqueSubjectID, sort: egen GroupATreatmentVG1=mean(ATreatmentVG1)
by UniqueSubjectID: gen GroupAVG1TreatmentAvg=GroupATreatmentVG1 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen AControlVG1=mean(Voting) if GroupA==1&VotingGame==1&Treatment==0
by UniqueSubjectID, sort: egen GroupAControlVG1=mean(AControlVG1)
by UniqueSubjectID: gen GroupAVG1ControlAvg=GroupAControlVG1 if _n==1


gen GroupAVG1AcorssTreatments=GroupAVG1TreatmentAvg if Treatment==1
replace GroupAVG1AcorssTreatments=GroupAVG1ControlAvg if Treatment==0
ttest GroupAVG1AcorssTreatments,by(Treatment)
ranksum GroupAVG1AcorssTreatments,by(Treatment)

/// Group B VG1
sort UniqueSubjectID
by UniqueSubjectID: egen BTreatmentVG1=mean(Voting) if GroupA==0&VotingGame==1&Treatment==1
by UniqueSubjectID, sort: egen GroupBTreatmentVG1=mean(BTreatmentVG1)
by UniqueSubjectID: gen GroupBVG1TreatmentAvg=GroupBTreatmentVG1 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen BControlVG1=mean(Voting) if GroupA==0&VotingGame==1&Treatment==0
by UniqueSubjectID, sort: egen GroupBControlVG1=mean(BControlVG1)
by UniqueSubjectID: gen GroupBVG1ControlAvg=GroupBControlVG1 if _n==1


gen GroupBVG1AcorssTreatments=GroupBVG1TreatmentAvg if Treatment==1
replace GroupBVG1AcorssTreatments=GroupBVG1ControlAvg if Treatment==0
ttest GroupBVG1AcorssTreatments,by(Treatment)
ranksum GroupBVG1AcorssTreatments,by(Treatment)

/// Group A VG2
sort UniqueSubjectID
by UniqueSubjectID: egen ATreatmentVG2=mean(Voting) if GroupA==1&VotingGame==2&Treatment==1
by UniqueSubjectID, sort: egen GroupATreatmentVG2=mean(ATreatmentVG2)
by UniqueSubjectID: gen GroupAVG2TreatmentAvg=GroupATreatmentVG2 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen AControlVG2=mean(Voting) if GroupA==1&VotingGame==2&Treatment==0
by UniqueSubjectID, sort: egen GroupAControlVG2=mean(AControlVG2)
by UniqueSubjectID: gen GroupAVG2ControlAvg=GroupAControlVG2 if _n==1


gen GroupAVG2AcorssTreatments=GroupAVG2TreatmentAvg if Treatment==1
replace GroupAVG2AcorssTreatments=GroupAVG2ControlAvg if Treatment==0
ttest GroupAVG2AcorssTreatments,by(Treatment)
ranksum GroupAVG2AcorssTreatments,by(Treatment)

/// Group B VG2
sort UniqueSubjectID
by UniqueSubjectID: egen BTreatmentVG2=mean(Voting) if GroupA==0&VotingGame==2&Treatment==1
by UniqueSubjectID, sort: egen GroupBTreatmentVG2=mean(BTreatmentVG2)
by UniqueSubjectID: gen GroupBVG2TreatmentAvg=GroupBTreatmentVG2 if _n==1

sort UniqueSubjectID
by UniqueSubjectID: egen BControlVG2=mean(Voting) if GroupA==0&VotingGame==2&Treatment==0
by UniqueSubjectID, sort: egen GroupBControlVG2=mean(BControlVG2)
by UniqueSubjectID: gen GroupBVG2ControlAvg=GroupBControlVG2 if _n==1


gen GroupBVG2AcorssTreatments=GroupBVG2TreatmentAvg if Treatment==1
replace GroupBVG2AcorssTreatments=GroupBVG2ControlAvg if Treatment==0
ttest GroupBVG2AcorssTreatments,by(Treatment)
ranksum GroupBVG2AcorssTreatments,by(Treatment)

restore
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////////            Results of Appendix J         ////////////////////////
///The results are based on the data of Current Population Survey, Voting and Registration Supplements 1968 to Present, historical table A-1. 
///Publicly available: https://www.census.gov/data/tables/time-series/demo/voting-and-registration/voting-historical-time-series.html.

log close OuPowerPaper
************************          The end          *****************************
